package com.xinxin.leetcode.problem520;

/**
 * @author ShiXinXin
 * @date 2020-01-12 22:12
 */
public class Solution {

    public boolean detectCapitalUse(String word) {
        char ch0 = word.charAt(0);
        if (ch0 >= 'A' && ch0 <= 'Z') {
            if (word.length() > 1) {
                char ch1 = word.charAt(1);
                if (ch1 >= 'A' && ch1 <= 'Z') {
                    return word.equals(word.toUpperCase());
                } else {
                    String str = word.substring(1);
                    return str.equals(str.toLowerCase());
                }
            } else {
                return true;
            }
        } else {
            return word.equals(word.toLowerCase());
        }
    }

    public static void main(String[] args) {
        System.out.println(new Solution().detectCapitalUse("USA"));
    }
}
